package com.cz.basetool.ui_work.util.et_bind;


import android.util.Pair;

import com.cz.basetool.ui_work.util.et_bind.base.BaseEditTextValidator;
import com.cz.basetool.ui_work.util.txt.CZ_TextUtil;
import com.cz.basetool.ui_work.util.txt.RegularUtil;

/**
 * Created by 陈章 on 2017/4/12 0012.
 * func:
 * 端口校验器
 */
public class PortValidator extends BaseEditTextValidator {
    public PortValidator() {
    }

    public PortValidator(OnValidatorResultObserver validatorResultObserver) {
        super(validatorResultObserver);
    }

    @Override
    public Pair validate(String txt) {
        if(CZ_TextUtil.is_null_or_empty(txt)){
            return getRightPair();
        }else{
            if(RegularUtil.isNumeric(txt)){
                return getRightPair();
            }else{
                return new Pair(false,"端口不为空必须是数字");
            }
        }
    }
}
